import 'package:enterprise_v6_app/generated/json/base/json_convert_content.dart';
import 'package:enterprise_v6_app/app/data/entities/application/standardiztion/standard_home_target_cert_entity.dart';

StandardHomeTargetCertEntity $StandardHomeTargetCertEntityFromJson(Map<String, dynamic> json) {
  final StandardHomeTargetCertEntity standardHomeTargetCertEntity = StandardHomeTargetCertEntity();
  final int? enterpriseSum = jsonConvert.convert<int>(json['enterpriseSum']);
  if (enterpriseSum != null) {
    standardHomeTargetCertEntity.enterpriseSum = enterpriseSum;
  }
  final int? deviceSum = jsonConvert.convert<int>(json['deviceSum']);
  if (deviceSum != null) {
    standardHomeTargetCertEntity.deviceSum = deviceSum;
  }
  final int? personnelSum = jsonConvert.convert<int>(json['personnelSum']);
  if (personnelSum != null) {
    standardHomeTargetCertEntity.personnelSum = personnelSum;
  }
  final List<StandardHomeTargetCertDeviceMap>? deviceMap = (json['deviceMap'] as List<dynamic>?)?.map(
          (e) => jsonConvert.convert<StandardHomeTargetCertDeviceMap>(e) as StandardHomeTargetCertDeviceMap).toList();
  if (deviceMap != null) {
    standardHomeTargetCertEntity.deviceMap = deviceMap;
  }
  final List<StandardHomeTargetCertPersonnelMap>? personnelMap = (json['personnelMap'] as List<dynamic>?)?.map(
          (e) => jsonConvert.convert<StandardHomeTargetCertPersonnelMap>(e) as StandardHomeTargetCertPersonnelMap).toList();
  if (personnelMap != null) {
    standardHomeTargetCertEntity.personnelMap = personnelMap;
  }
  return standardHomeTargetCertEntity;
}

Map<String, dynamic> $StandardHomeTargetCertEntityToJson(StandardHomeTargetCertEntity entity) {
  final Map<String, dynamic> data = <String, dynamic>{};
  data['enterpriseSum'] = entity.enterpriseSum;
  data['deviceSum'] = entity.deviceSum;
  data['personnelSum'] = entity.personnelSum;
  data['deviceMap'] = entity.deviceMap?.map((v) => v.toJson()).toList();
  data['personnelMap'] = entity.personnelMap?.map((v) => v.toJson()).toList();
  return data;
}

extension StandardHomeTargetCertEntityExtension on StandardHomeTargetCertEntity {
  StandardHomeTargetCertEntity copyWith({
    int? enterpriseSum,
    int? deviceSum,
    int? personnelSum,
    List<StandardHomeTargetCertDeviceMap>? deviceMap,
    List<StandardHomeTargetCertPersonnelMap>? personnelMap,
  }) {
    return StandardHomeTargetCertEntity()
      ..enterpriseSum = enterpriseSum ?? this.enterpriseSum
      ..deviceSum = deviceSum ?? this.deviceSum
      ..personnelSum = personnelSum ?? this.personnelSum
      ..deviceMap = deviceMap ?? this.deviceMap
      ..personnelMap = personnelMap ?? this.personnelMap;
  }
}

StandardHomeTargetCertDeviceMap $StandardHomeTargetCertDeviceMapFromJson(Map<String, dynamic> json) {
  final StandardHomeTargetCertDeviceMap standardHomeTargetCertDeviceMap = StandardHomeTargetCertDeviceMap();
  final String? name = jsonConvert.convert<String>(json['name']);
  if (name != null) {
    standardHomeTargetCertDeviceMap.name = name;
  }
  final int? value = jsonConvert.convert<int>(json['value']);
  if (value != null) {
    standardHomeTargetCertDeviceMap.value = value;
  }
  return standardHomeTargetCertDeviceMap;
}

Map<String, dynamic> $StandardHomeTargetCertDeviceMapToJson(StandardHomeTargetCertDeviceMap entity) {
  final Map<String, dynamic> data = <String, dynamic>{};
  data['name'] = entity.name;
  data['value'] = entity.value;
  return data;
}

extension StandardHomeTargetCertDeviceMapExtension on StandardHomeTargetCertDeviceMap {
  StandardHomeTargetCertDeviceMap copyWith({
    String? name,
    int? value,
  }) {
    return StandardHomeTargetCertDeviceMap()
      ..name = name ?? this.name
      ..value = value ?? this.value;
  }
}

StandardHomeTargetCertPersonnelMap $StandardHomeTargetCertPersonnelMapFromJson(Map<String, dynamic> json) {
  final StandardHomeTargetCertPersonnelMap standardHomeTargetCertPersonnelMap = StandardHomeTargetCertPersonnelMap();
  final String? name = jsonConvert.convert<String>(json['name']);
  if (name != null) {
    standardHomeTargetCertPersonnelMap.name = name;
  }
  final int? value = jsonConvert.convert<int>(json['value']);
  if (value != null) {
    standardHomeTargetCertPersonnelMap.value = value;
  }
  return standardHomeTargetCertPersonnelMap;
}

Map<String, dynamic> $StandardHomeTargetCertPersonnelMapToJson(StandardHomeTargetCertPersonnelMap entity) {
  final Map<String, dynamic> data = <String, dynamic>{};
  data['name'] = entity.name;
  data['value'] = entity.value;
  return data;
}

extension StandardHomeTargetCertPersonnelMapExtension on StandardHomeTargetCertPersonnelMap {
  StandardHomeTargetCertPersonnelMap copyWith({
    String? name,
    int? value,
  }) {
    return StandardHomeTargetCertPersonnelMap()
      ..name = name ?? this.name
      ..value = value ?? this.value;
  }
}
